package cn.itcast.web.servlet;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.util.List;

public class UserMapperTest {
    @Test
    public void selectall()throws Exception{
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("mybatis-config.xml"));
        SqlSession sqlSession = sqlSessionFactory.openSession();

        List<user> users = sqlSession.selectList("UserMapper.selectAll");
        for (user user : users) {
            System.out.println(user);
        }

        sqlSession.close();
    }
}
